
/*
 * Problem: 下一个排列
 * Author: Yuanshun L
 * Created: 9-Nov-2021
 * Method: next_permutaion法
 */

#include<iostream>
#include<algorithm>

using namespace std;
const int n = 6;
int target[] = {1,5,1,3,4,2};
int cnt = 0;



int main(){

    freopen("data.in","r",stdin);
    freopen("data.out","w",stdout);

    sort(target,target+n);

    do{
        for(int i=0;i<n;i++){
            cout<< target[i] << " ";
        }
        cout<<endl;
        cnt ++;
    }while(next_permutation(target,target+n));
    // 对可重和不可重集均适用

    cout<< "The Number of Possibility :"<<cnt<<endl;
    return 0;
}